package com.pw.gmall.realtime.function;

import org.apache.flink.table.annotation.DataTypeHint;
import org.apache.flink.table.annotation.FunctionHint;
import org.apache.flink.table.functions.TableFunction;
import org.apache.flink.types.Row;

/**
 * @Author: linux_future
 * @since: 2022/3/28
 **/
@FunctionHint(output = @DataTypeHint("ROW<source string,ct bigint>"))
public class KwProduct extends TableFunction<Row> {

    public void eval(Long click_ct, Long cart_ct, Long order_ct) {
        if (click_ct > 0) {
            collect(Row.of("click", click_ct));
        }
        if (cart_ct > 0) {
            collect(Row.of("cart", cart_ct));
        }
        if (order_ct > 0) {
            collect(Row.of("order", order_ct));
        }
    }
}
